<?php

namespace Admin\Controller;

use Think\Controller;

class ExposureOrderController extends Controller {

    public function exposureOrderList() {

        $map = array();
        $username = trim(I('get.username'));
        $exposure_content = trim(I('get.exposure_content'));
        $status = intval(I('get.status'));
        //用户名搜索
        if ($username && $username != "") {
            $map['u.username'] = array('like', "%$username%");
        }
        //内容搜索
        if ($exposure_content && $exposure_content != "") {
            $map['e.exposure_content'] = array('like', "%$exposure_content%");
        }
        //状态搜索
        if ($status && $status != "") {
            $map['e.status'] = array('like', "%$package_name%");
        }
        $exposureOrder = D("Home/ExposureOrder");
        $result = $exposureOrder->exposureOrderlist($map, "e.*,u.username,u.id as uid", C("DB_PREFIX") . "user u on e.user_id=u.id", "e");
        $this->assign('exposureOrder', $result['comList']);
        $this->assign('page', $result['page']);
        $this->display();
    }

    /*
     * 查看曝光订单详情
     */

    public function exposureOrderById() {
        $exposure = D('Home/ExposureOrder');
        $id = intval(I('post.id'));
        if (!$id) {
            $arr['status'] = 100;
            $arr['info'] = "参数不合法，请刷新重试";
        } else {
            $relust = $exposure->getDataById("id=" . $id);
            $relust['package_name'] = M("exposure_package")->where(array('id' => $relust['package_id']))->getField("package_name");
            $relust['status'] = $relust['status'] == 1 ? "已审核" : $relust['status'] == 2 ? "审核失败" : "未审核";
            $relust['imgs'] = is_array(explode(",", $relust['exposure_imgs'])) ? explode(",", $relust['exposure_imgs']) : $relust['exposure_imgs'];
            if (count($relust) < 0) {
                $arr['status'] = 100;
                $arr['info'] = "查询失败，请刷新重试";
            } else {
                $arr['status'] = 200;
                $arr['info'] = $relust;
            }
        }
        $this->ajaxReturn($arr);
    }
    
    /*
     * 订单完成，提交反馈文件供用户下载
     * csb
     */
    public function orderComplete()
    {
       
       ECHO      $_FILES['userfile']['name'] ."</br>";//: 客户端机器文件的原名称
         ECHO     $_FILES['userfile']['type']."</br>";// : 文件的MIME类型
        ECHO      $_FILES['userfile']['size']."</br>";// : 已上传的文件大小
         ECHO     $_FILES['userfile']['tmpname']."</br>";// : 文件被上传后在服务器存储的临时文件名
         ECHO     $_FILES['userfile']['error'];// : 和该文件上传的错误代码
        exit;
    }

}
